package server;

import net.sf.json.JSONObject;

import java.util.Date;

/**
 * User: tum0r
 * Package Name: server
 * Time: 2019-03-11 Monday 17:49:52
 */
public class LoginThreadServer extends BaseServer implements Runnable {

    @Override
    public void run() {
        while(true){
            JSONObject result = JSONObject.fromObject(sql.query("select content from setting where name=?",new Object[]{"cookie"}).get(0).get("content").toString());
            long timeLimit = Long.parseLong(result.getString("timeLength"));
            sql.update("delete from login where ?-time>?",new Object[]{new Date().getTime(),timeLimit});
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
